package com.zhanggm.springcloud.jpa.controller;

import com.zhanggm.springcloud.jpa.dao.OrderRepositroy;
import com.zhanggm.springcloud.jpa.dao.RoleRepositroy;
import com.zhanggm.springcloud.jpa.dao.UserRepositroy;
import com.zhanggm.springcloud.jpa.entity.UserEntity;
import com.zhanggm.springcloud.jpa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JpaController {
    @Autowired
    private OrderRepositroy orderRepositroy;

    @Autowired
    private UserRepositroy userRepositroy;

    @Autowired
    private RoleRepositroy roleRepositroy;

    @Autowired
    private UserService userService;

    @RequestMapping("user")
    public Object user(){
        return userRepositroy.findAll();
    }

    @RequestMapping("order")
    public Object order(){
        return orderRepositroy.findAll();
    }

    @RequestMapping("role")
    public Object role(){
        return roleRepositroy.findAll();
    }

    @RequestMapping("getPageInfo")
    public Object getPageInfo(UserEntity userEntity, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize){
        return userService.getList(userEntity,pageNum,pageSize);
    }

}
